In a video coding/decoding system, a picture may be divided into several image blocks or macroblocks, and motion estimation is carried out based on blocks or macroblocks. The residual after motion estimation is transformed and quantized. Finally, entropy coding is performed on the quantized coefficient and the information obtained after the entropy coding is written into a bit stream. After a picture is divided into macroblocks, the macroblocks will be organized into slices.
In a video coding/decoding system, after the decoder receives video packets from the encoder, the decoder will organize contents in the data packets according to a certain rule and obtain a reconstructed picture after dequantization, detranformation and motion compensation.
In the conventional art, in a video coding/decoding system, slice division methods include:
1. Method Defined by Moving Picture Experts Group 2 (MPEG-2)
According to MPEG-2, a slice (block group) is defined as a series of any number of macroblocks. A block group includes at least one macroblock and no overlap should exist between any two block groups. The first and the last macroblocks in a block group must be in one macroblock row. Block groups appear in a bit stream from left to right and from the top down following the optical grating scanning sequence starting with the upper left corner of a picture.
During the implementation of the invention, the inventor discovers at least the following weaknesses in the conventional art:
(1) MPEG-2 requires the first macroblock and the last macroblock appear in a same macroblock row, which restricts the flexibility of block groups in length and spatial distribution. One block group can include macroblocks in at most one horizontal row so that the flexibility of a coding/decoding system is restricted.
(2) In certain scenarios, coding and decoding of a macroblock cannot use information of adjacent macroblocks and thus the efficiency of coding and decoding is low.
(3) Because block groups must appear in a bit stream in the sequence of being met, a picture cannot be sliced or encoded based on multiple macroblock rows or based on regions or objects.
2. Method Defined by H.264
In the H.264 standard, a slice is defined as an integer number of macroblocks or macroblock pairs arranged in the optical grating scanning sequence inside a specific slice set. Although a slice contains an integer number of macroblocks or macroblock pairs arranged in the optical grating scanning sequence inside a slice group, the macroblocks or macroblock pairs are not necessarily arranged continuously in the optical grating scanning sequence within a picture. A macroblock address is obtained through the address of the first macroblock and the mapping from the macroblock to a slice group. A slice group is defined as a subset of macroblocks or macroblock pairs in the picture. To divide a picture into slice groups is to organize certain macroblocks in the picture into a slice group according to the mapping from macroblocks to slice groups, which means macroblocks are organized according to certain spatial mappings.
During the implementation of the invention, the inventor finds at least the following weaknesses in the conventional art:
(1) Because the mapping from macroblocks to slice groups is stored in the picture header, an extra storage cost is imposed on the encoder and the decoder. Besides, the encoder must know the spatial mappings of macroblocks in advance, which is not good for real-time coding.
(2) Because of the mapping of macroblocks, it is unnecessary for macroblocks in one slice to be continuous in the optical grating scanning sequence so that the encoder and the decoder have to provide an extra storage space to store macroblocks that are not encoded and decoded in a slice.
(3) Because macroblocks in one slice or one slice group are not continuous in the optical grating scanning sequence, the encoder and the decoder must continuously search for and locate the physical addresses of adjacent macroblocks, which causes an additional computing cost.